/*
CVAR:
	- amx_il_active	(1)
		1/0 -	Wlacza/wylacza plugin
			
	- amx_il_time	(5)
		- 	Czas w sekundach co ile wartosci sa ustawiane jesli amx_il_lock_type = 1
	
	- amx_il_rate_lock (1)
		1/0 - Wlacza/wylacza wymuszanie rate
	
	- amx_il_rate_val (25000)
		-	Wartosc rate
	
	- amx_il_interp_lock (1)
		1/0 - Wlacza/wylacza wymuszanie interpu

	- amx_il_interp_val (0.01)
		-	Wartosc ex_interp
	
	- amx_il_show_ip (1)
		1/0 - Wlacza/wylacza pokazywanie ip przy say /ip

	- amx_il_minmodels_lock (1)
		1/0 - Wlacza/wylacza wymuszanie cl_minmodels 1
*/
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Interp lock"
#define VERSION "1.0"
#define AUTHOR "Zabijaka"

new gCvarActive;
new gCvarTaskTime;
new gCvarRateLock;
new gCvarRateVal;
new gCvarInterpLock;
new gCvarInterpVal;
new gCvarModelsLock;
new gCvarShowIp;

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)  ;
	
	gCvarActive = register_cvar("amx_il_active", "1");
	gCvarTaskTime = register_cvar("amx_il_time", "5");
	gCvarRateLock = register_cvar("amx_il_rate_lock", "1");
	gCvarRateVal = register_cvar("amx_il_rate_val", "25000");
	gCvarInterpLock = register_cvar("amx_il_interp_lock", "1");
	gCvarInterpVal = register_cvar("amx_il_interp_val", "0.01");
	gCvarModelsLock = register_cvar("amx_il_minmodels_lock", "1");
	gCvarShowIp = register_cvar("amx_il_show_ip", "1");
	
	register_clcmd("say /ip", "showIp");

}


public showIp(id,level,cid){
	if(!get_pcvar_num(gCvarShowIp))
		return PLUGIN_CONTINUE;
	
	new players[32];
	new player;
	new num;
	new name[36];
	new ip[16];
	new steam[24];
	get_players(players, num, "ch");
	for(new i=0;i<num;i++){
		player = players[i];
		get_user_name(player, name, charsmax(name));
		get_user_ip(player, ip, charsmax(ip), 1);
		get_user_authid(player, steam, charsmax(steam));
		
		client_print(id, print_console, "Nick: %s, IP: %s, Steam: %s", name, ip,steam);
	}
	client_print(id, print_chat, "IP i Steam wypisano w konsoli.");
	return PLUGIN_CONTINUE;
}



public plugin_cfg(){
	set_task(2.0, "startMonitoring");
}

public startMonitoring(){
	set_task(float(get_pcvar_num(gCvarTaskTime)), "setUserValues", _,_,_,"b");
}

public setUserValues() {
	if(!get_pcvar_num(gCvarActive))
		return;
	if(get_pcvar_num(gCvarInterpLock)){
		new Float:interp = get_pcvar_float(gCvarInterpVal);
		interp = floatclamp(interp, 0.01, 0.05);
		client_cmd(0, "ex_interp %f", interp);
	}
	if(get_pcvar_num(gCvarRateLock)){
		new rate = get_pcvar_num(gCvarRateVal);
		rate = clamp(rate, 10000, 25000);
		client_cmd(0, "rate %d", rate);
	}
	if(get_pcvar_num(gCvarModelsLock)){
		client_cmd(0, "cl_minmodels 0");
	}
}
